<template>
  <div class="drawer-select">
    <section v-if="!isBegin" class="drawer-select-empty">
      <el-button type="primary" :icon="Plus" link @click="onBegin">开始绘制</el-button>
    </section>
    <section v-else class="drawer-select-main">
        <el-steps :active="stepIndex" finish-status="success" align-center>
          <el-step @click="onStepClick(0)">
            <template #title>
              <el-dropdown :ref="el => dropdownRefs[0] = el" trigger="contextmenu">
              <span>安全力量</span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item :icon="Plus">Action 1安全力量</el-dropdown-item>
                  <el-dropdown-item :icon="Plus">
                    Action 2
                  </el-dropdown-item>
                  <el-dropdown-item :icon="Plus">Action 3</el-dropdown-item>
                  <el-dropdown-item :icon="Plus">Action 4</el-dropdown-item>
                  <el-dropdown-item :icon="Plus">Action 5</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
            </template>
          </el-step>
          <el-step @click="onStepClick(1)">
            <template #title>
              <el-dropdown :ref="el => dropdownRefs[1] = el" trigger="contextmenu">
              <span>力量资源</span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item :icon="Plus">Action 1力量资源</el-dropdown-item>
                  <el-dropdown-item :icon="Plus">
                    Action 2
                  </el-dropdown-item>
                  <el-dropdown-item :icon="Plus">Action 3</el-dropdown-item>
                  <el-dropdown-item :icon="Plus">Action 4</el-dropdown-item>
                  <el-dropdown-item :icon="Plus">Action 5</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
            </template>
          </el-step>
          <el-step @click="onStepClick(2)">
            <template #title>
              <el-dropdown :ref="el => dropdownRefs[2] = el" trigger="contextmenu">
              <span>标绘方式</span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item :icon="Plus">Action 1标绘方式</el-dropdown-item>
                  <el-dropdown-item :icon="Plus">
                    Action 2
                  </el-dropdown-item>
                  <el-dropdown-item :icon="Plus">Action 3</el-dropdown-item>
                  <el-dropdown-item :icon="Plus">Action 4</el-dropdown-item>
                  <el-dropdown-item :icon="Plus">Action 5</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
            </template>
          </el-step>
        </el-steps>
      </section>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { Plus } from '@element-plus/icons-vue';

const isBegin = ref(false);
const stepIndex = ref(1);
const dropdownRefs = ref([]);

const onStepClick = async index => {
  if (index > stepIndex.value) return;
  console.log('onStepClick', index, dropdownRefs.value);
  dropdownRefs.value[index].handleOpen();
};

const onBegin = () => {
  isBegin.value = true;
};
</script>

<style lang="scss" scoped>
.drawer-select {
  height: 100%;
  margin: 0 var(--ycy-gap-base);
  padding: var(--ycy-gap-base);
  border-radius: var(--el-border-radius-base);
  background-color: var(--el-fill-color-blank);

  .drawer-select-empty {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--el-text-color-secondary);
    font-size: var(--el-font-size-small);

    .el-icon {
      margin-right: var(--ycy-gap-small);
    }
  }
}
</style>